package com.bdqn.util;

import java.util.List;

public class Page<T> {
    //当前页面
    private Long currentPageNo;
    // 页面大小，即每页显示的记录数
    private Long pageSize = 3l;
    // 总数据量
    private Long totalCount;
    
    // 总页数
    private Long totalPageCount;
    // 分页数据
    private List<T> data;

    public Long getCurrentPageNo() {
        return currentPageNo;
    }

    public void setCurrentPageNo(Long currentPageNo) {
        this.currentPageNo = currentPageNo<=0?1:Math.min(currentPageNo,this.totalPageCount==0?1:this.totalPageCount);
    }

    public Long getPageSize() {
        return pageSize;
    }

    public void setPageSize(Long pageSize) {
        this.pageSize = pageSize;
    }

    public Long getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(Long totalPageCount) {
        this.totalPageCount = totalPageCount;
        // 计算totalPage（总页数）
        this.totalPageCount = this.totalPageCount % this.pageSize == 0 ?
                (this.totalPageCount / this.pageSize) :
                (this.totalPageCount / this.pageSize + 1);
    }

    public Long getTotalPage() {
        return totalPageCount;
    }

    public void setTotalPage(Long totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public Long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Long totalCount) {
        this.totalCount = totalCount;
    }
}
